<?php

namespace app\admin\model;

use think\Model;


class Worker extends Model
{


    protected	$pk	=	'workerid';


    // 表名
    protected $name = 'worker';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];
    

    public function workinfo()
    {
        return $this->hasOne('Workinfo', 'workerid', 'workerid', [], 'LEFT')->setEagerlyType(0);
    }

    //关联新增
    public function relsave($pk,$data){
        $this->find($pk);
        $this->workinfo()->save($data);
    }

    public function designer(){
        return $this->belongsTo('Admin','admin_id','id',[],'RIGHT')->bind('username,nickname,email');
    }
    public function comments(){
        return $this->hasMany('Comment','workerid','workerid','LEFT');
    }
}
